
 <link rel="stylesheet" type="text/css" href="css/validationEngine.jquery.css">
<link rel="stylesheet" type="text/css" href="css/template.css">

<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validationEngine-vi.js"></script>
<script type="text/javascript" src="js/jquery.validationEngine.js"></script>
<script>
        jQuery(document).ready(function(){
            // binds form submission and fields to the validation engine
            jQuery("#formID").validationEngine();
        });
</script>
<script>function Del_Info(str){
	var q=confirm('Bạn có chắc chắn muốn xóa hay không?');	
	if(q==true) 
		window.location=str;
	
}
</script>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css"/>
 
  <script type="text/javascript" src="js/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();
  </script>
   <script>
  $(function() {
    $( "#datepicker1" ).datepicker();
  });
  var date = $('#datepicker1').datepicker({ dateFormat: 'dd-mm-yy' }).val();
  </script>
<?php
$sql="SELECT substr( QUYEN,1, 1 ) as mq
FROM qldl_tai_khoan
WHERE ten_dang_nhap = '".$_SESSION['username']."'";
	$query = @mysql_query($sql,$conn);
	$row = @mysql_fetch_array($query);
	if($row['mq']==1){
	 header('Location: index.php?page=id_edit_tour&amp;id_edit_tour="'.$_GET['id_edit_tour'].'"'); 
	}
	else {
	echo  "<script>alert ('B?n không có quy?n truy c?p trang này!')</script>"; 
	echo "<meta http-equiv='refresh' content='0;url= index.php'>";
	}
	
?>
<div class="cpanel-right-tttk">
  <div id="panel-sliders" class="pane-sliders">
    <div class="panel">
    
      <table width="100%" border="0" cellspacing="0" cellpadding="0" style=" padding:10px;">
        <thead>
        <tr style=" padding-bottom:10px;">
        <th colspan="3" align="left" style="padding-bottom:10px;">QUẢN LÍ DANH MỤC TOUR</th>
        </tr> 
        </thead> 
        <tr valign="top" style="padding:5px;">
          <td width="40%"><div style=" padding:0px; border-top: medium none; border-bottom: medium none; overflow: hidden; height: auto; width:100%" align="left">
            <form name="formID" id="formID" action="" method="post" enctype="multipart/form-data" >
            <table width="97%" height="477" border="1" bordercolor="#666666" class="adminlist_tt">
              <thead>
                <tr>
                  <th colspan="3"> Sửa thông tin tour</th>
                </tr>
                <?php 
				
					if(isset($_POST['btn_edit_tour'])){
					$mt = $_POST['txt_ma_tour'];
					$kt = $_POST['chon_kt'];
					$tt = $_POST['txt_ten_tour'];
					$gia = $_POST['txt_gia'];
					$tgkh = $_POST['txt_tg_kh'];
					$tgkt = $_POST['txt_tg_kt'];
					$sn = $_POST['txt_so_ngay'];
					$sc = $_POST['txt_so_cho'];
					$dg = $_POST['area'];
					$date = $tgkh;
					$arr_date = explode("/",$date);
					$day = $arr_date[1];
					$month = $arr_date[0];
					$year = $arr_date[2];
					$ngay = $year."-".$month."-".$day;	
					
					$date1 = $tgkt;
					$arr_date1 = explode("/",$date1);
					$day1 = $arr_date1[1];
					$month1 = $arr_date1[0];
					$year1 = $arr_date1[2];
					$ngay_kt = $year1."-".$month1."-".$day1;
					 
					 if ($_FILES["file_up"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file_up"]["error"] . "<br />";
    }
  else
    {$link = "tour/upload/news/" . $_FILES["file_up"]["name"];
    if (file_exists("tour/upload/news/" . $_FILES["file_up"]["name"]))
      {
      echo $_FILES["file_up"]["name"] . " da ton tai file tren server. ";
      }
    else
      {  
      move_uploaded_file($_FILES["file_up"]["tmp_name"],
      "tour/upload/news/" . $_FILES["file_up"]["name"]);	
      }
	$sql2="select * from qldl_tour ";
		$query2 = @mysql_query($sql2,$conn);
		if(!$query2) echo "Query error to display.";
	else $row2 = @mysql_fetch_array($query2);
	/////
	
if($link==''){
		$link=$row2['HINH_ANH'];
		}
	}
	/////
	
$sql2="select * from qldl_tour ";
		$query2 = @mysql_query($sql2,$conn);
		if(!$query2) echo "Query error to display.";
	else $row2 = @mysql_fetch_array($query2);
	/////
	
if($link==''){
		$link=$row2['HINH_ANH'];
		}
		$sql = "update qldl_tour set				
				MA_KIEU='$kt',
				TEN_TOUR='$tt',
				GIA='$gia',
				TG_KHOI_HANH='$ngay',
				TG_KET_THUC='$ngay_kt',
				SO_NGAY='$sn',
				SO_CHO='$sc',
				DIEN_GIAI='$dg',
				HINH_ANH='$link'
			where MA_TOUR='$mt'
			";
	$query = @mysql_query($sql,$conn);
		
	if(isset($_POST['btn_edit_tour'])){
 					$d1 = $_POST['dd1'];
					$d2 = $_POST['dd2'];
					$d3 = $_POST['dd3'];
					$d4 = $_POST['dd4'];
					$d5 = $_POST['dd5'];
					$p1 = $_POST['pt1'];
					$p2 = $_POST['pt2'];
					$p3 = $_POST['pt3'];
					$p4 = $_POST['pt4'];
					$sql_xl1="select * from qldl_chi_tiet_tour			
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl1 = @mysql_query($sql_xl1,$conn);	
								$row_xl1 = @mysql_fetch_array($query_xl1);
					/////////			
					$sql_xl2="select * from qldl_chi_tiet_tour
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl2 = @mysql_query($sql_xl2,$conn);	
								$row_xl2 = @mysql_fetch_array($query_xl2);
								//////////
					$sql_xl2="select * from qldl_chi_tiet_tour
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl3 = @mysql_query($sql_xl3,$conn);	
								$row_xl3 = @mysql_fetch_array($query_xl3);
								//////
					$sql_xl4="select * from qldl_chi_tiet_tour
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl4 = @mysql_query($sql_xl4,$conn);	
								$row_xl4 = @mysql_fetch_array($query_xl4);
								/////////////////////
					$sql_xl5="select * from qldl_chi_tiet_tour
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl5 = @mysql_query($sql_xl5,$conn);	
								$row_xl5 = @mysql_fetch_array($query_xl5);
								/////////////////////
					$sql_xl6="select * from qldl_chi_tiet_phuong_tien
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl6 = @mysql_query($sql_xl6,$conn);	
								$row_xl6 = @mysql_fetch_array($query_xl6);
								////////////////////////
					$sql_xl7="select * from qldl_chi_tiet_phuong_tien
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl7 = @mysql_query($sql_xl7,$conn);	
								$row_xl7 = @mysql_fetch_array($query_xl7);
								//////////////////////////
					$sql_xl8="select * from qldl_chi_tiet_phuong_tien
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl8 = @mysql_query($sql_xl8,$conn);	
								$row_xl8 = @mysql_fetch_array($query_xl8);
								//////////////////////////
					$sql_xl9="select * from qldl_chi_tiet_phuong_tien
										
							where MA_TOUR='".$_GET['id_edit_tour']."'";
						$query_xl9 = @mysql_query($sql_xl9,$conn);	
								$row_xl9 = @mysql_fetch_array($query_xl9);
								//////////////////////////
						
					if($_POST['dd1']<>""){
					$sql1 = "update qldl_chi_tiet_tour set MA_DIA_DIEM='$d1' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_DIA_DIEM='".$row_xl1['MA_DIA_DIEM']."'";
					$query1 = @mysql_query($sql1,$conn);	
					}
					if($_POST['dd2']<>''){
					$sql2 = "update qldl_chi_tiet_tour set MA_DIA_DIEM='$d2' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_DIA_DIEM='".$row_xl2['MA_DIA_DIEM']."'";
					$query2 = @mysql_query($sql2,$conn);		
					}else {
					$sql_n2 = "INSERT INTO qldl_chi_tiet_tour VALUES('$d2','$mt')";
					$queryn2 = @mysql_query($sql_n2,$conn);	
					}
					if($_POST['dd3']<>''){
					$sql3 = "update qldl_chi_tiet_tour set MA_DIA_DIEM='$d3' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_DIA_DIEM='".$row_xl3['MA_DIA_DIEM']."'";
					
					$query3 = @mysql_query($sql3,$conn);		
					}
					if($_POST['dd4']<>''){
					$sql4 = "update qldl_chi_tiet_tour set MA_DIA_DIEM='$d4' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_DIA_DIEM='".$row_xl4['MA_DIA_DIEM']."'";
					
					$query4 = @mysql_query($sql4,$conn);		
					}
					if($_POST['dd5']<>''){
					$sql5 = "update qldl_chi_tiet_tour set MA_DIA_DIEM='$d5' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_DIA_DIEM='".$row_xl5['MA_DIA_DIEM']."'";
				
					$query5 = @mysql_query($sql5,$conn);		
					}
					if($_POST['pt1']<>''){
					$sql6 = "update qldl_chi_tiet_phuong_tien set MA_PHUONG_TIEN='$p1' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_PHUONG_TIEN='".$row_xl6['MA_PHUONG_TIEN']."'";
					$query6 = @mysql_query($sql6,$conn);
					}
					if($_POST['pt2']<>''){
					$sql7 = "update qldl_chi_tiet_phuong_tien set MA_PHUONG_TIEN='$p2' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_PHUONG_TIEN='".$row_xl7['MA_PHUONG_TIEN']."'";
					$query7 = @mysql_query($sql7,$conn);	
					}
					if($_POST['pt3']<>''){
					$sql8 = "update qldl_chi_tiet_phuong_tien set MA_PHUONG_TIEN='$p3' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_PHUONG_TIEN='".$row_xl8['MA_PHUONG_TIEN']."'";
					$query8 = @mysql_query($sql8,$conn);
					}
					if($_POST['pt4']<>''){
					$sql9 = "update qldl_chi_tiet_phuong_tien set MA_PHUONG_TIEN='$p4' where MA_TOUR='".$_GET['id_edit_tour']."' AND MA_PHUONG_TIEN='".$row_xl9['MA_PHUONG_TIEN']."'";
					$query9 = @mysql_query($sq9,$conn);
					}
	}
	
	if($query)echo "<script>alert ('Cập nhật thông tin thành công.')</script>";	
	else echo "<script>alert ('Lỗi cập nhật thông tin!')</script>";	
}
					?>
              </thead>
            <tbody>
            <?php  
	$sql="select * from qldl_tour where MA_TOUR='".$_GET['id_edit_tour']."'";
	$query = @mysql_query($sql,$conn);	
	if(!$query) echo "Query error to display.";
	else $row = @mysql_fetch_array($query);	
  ?>
                <tr>
                  <td>Mã tour</td>
                  <td colspan="2">
                    <label for="txt_ma_tour"></label>
                    <input type="text" readonly="readonly" value="<?php echo $row['MA_TOUR'];?>" name="txt_ma_tour" id="txt_ma_tour" class="validate[required] text-input"/>
                  <!-- class="validate[required,custom[onlyNumberSp]]"-->
                  </td>
                  </tr>
                <tr>
                  <td>Kiểu tour</td>
                  <td colspan="2">
                     <?php
						$sql_ttp1="select * from qldl_kieu_tour where MA_KIEU='".$_GET['id_kt']."'";
						$query_ttp1 = @mysql_query($sql_ttp1,$conn);	
							if(!$query_ttp1)echo "Query error to display.";
							else
								$row_ttp1 = @mysql_fetch_array($query_ttp1);
						?>
                    <select id="chon_kt" class="validate[required]" name="chon_kt">	
						<option value="<?php echo $row_ttp1['MA_KIEU']?>" selected><?php echo $row_ttp1['TEN']?></option>
						<?php 
							$sql_ttp="select * from qldl_kieu_tour order by MA_KIEU asc";
							$query_ttp = @mysql_query($sql_ttp,$conn);
							 while($row_ttp = mysql_fetch_array($query_ttp)){
						?>  
						<option value="<?php echo $row_ttp['MA_KIEU'];?>"><?php echo $row_ttp['TEN'];?></option>
							<?php }?> 
					</select>
                    </td>
                </tr>
                <tr>
                  <td>Tên tour</td>
                  <td colspan="2">
                    <label for="txt_ten_tour"></label>
                    <input type="text" value="<?php echo $row['TEN_TOUR'];?>" class="validate[required] text-input" name="txt_ten_tour" id="txt_ten_tour" />
                  </td>
                  </tr>
                <tr>
                  <td>Giá</td>
                  <td colspan="2">
                    <label for="txt_gia"></label>
                    <input type="text" value="<?php echo $row['GIA'];?>" class="validate[required] text-input" name="txt_gia" id="txt_gia" />
                  </td>
                  </tr>
                <tr>
                  <td>Thời gian khởi hành</td>
                  <td colspan="2">
                    <label for="txt_tg_khoi_hanh"></label>
                   <input type="text" value="<?php   
				  $date = $row['TG_KHOI_HANH'];
					$arr_date = explode("-",$date);
					$day = $arr_date[1];
					$month = $arr_date[2];
					$year = $arr_date[0];
					$ngay_kh = $day."/".$month."/".$year;	
				  echo $ngay_kh;?>" class="validate[required] text-input" size="12" name="txt_tg_kh" id="datepicker">
                  </td>
                  </tr>
                <tr>
                  <td>Thời gian kết thúc</td>
                  <td colspan="2">
                    <label for="txt_tg_ket_thuc"></label>
                    <input type="text" value="<?php   
				  	$date = $row['TG_KET_THUC'];
					$arr_date = explode("-",$date);
					$day = $arr_date[1];
					$month = $arr_date[2];
					$year = $arr_date[0];
					$ngay_kh = $day."/".$month."/".$year;	
				  echo $ngay_kh;?>" class="validate[required] text-input" id="datepicker1" size="12" name="txt_tg_kt" align="left"/>
                  </td>
                  </tr>
                <tr>
                  <td>Số ngày</td>
                  <td colspan="2">
                    <label for="txt_so_ngay"></label>
                    <input type="text" value="<?php echo $row['SO_NGAY'];?>" class="validate[required] text-input" name="txt_so_ngay" id="txt_so_ngay" />
                  </td>
                  </tr>
                <tr>
                  <td>Số chỗ </td>
                  <td colspan="2">
                    <label for="txt_so_cho"></label>
                    <input type="text" value="<?php echo $row['SO_CHO'];?>"class="validate[required] text-input" name="txt_so_cho" id="txt_so_cho" />
                  </td>
                  </tr>
                <tr>
                  <td>Diễn giải</td>
                  <td colspan="2">
                    <label for="area_dien_giai"></label>
                    <textarea value="" name="area" id="area" cols="45" rows="5"><?php echo $row['DIEN_GIAI'];?></textarea>
                  </td>
                  </tr>
                <tr>
                  <td>Hình ảnh</td>
                  <td colspan="2">
                    <label for="txt_hinh_anh"></label>
                    <input type="file" name="file_up" value="<?php echo $row['HINH_ANH']; ?>" />
                  </td>
                  </tr>
                   <tr>
                  <td colspan="3" align="center"><strong>Cập nhật địa điểm du lịch</strong></td>
                </tr>
                <tr>
                  <td>Địa điểm 1</td>
                  <td colspan="2">
                  <?php
						$sql_dd1="select * from qldl_chi_tiet_tour
										inner join qldl_dia_diem_du_lich
										on qldl_chi_tiet_tour.MA_DIA_DIEM = qldl_dia_diem_du_lich.MA_DIA_DIEM 
										 where qldl_chi_tiet_tour.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 0,1";
						$query_dd1 = @mysql_query($sql_dd1,$conn);	
								$row_dd1 = @mysql_fetch_array($query_dd1);
						?>
                    <select name="dd1" id="dd1" class="validate[trung[dd2],trung[dd3],trung[dd4],trung[dd5]]"  >
                    <option value="<?php echo $row_dd1['qldl_dia_diem_du_lich.MA_DIA_DIEM']?>" 
                    selected><?php echo $row_dd1['DIA_DIEM']?></option>
					<?php 
							$sql_dd="select * from qldl_dia_diem_du_lich order by MA_DIA_DIEM asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)
							while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
					<option value="<?php echo $row_dd['MA_DIA_DIEM'];?>"><?php echo $row_dd['DIA_DIEM'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td>Địa điểm 2</td>
                  <td colspan="2">
                  <?php
				  
						$sql_dd2="select * from qldl_chi_tiet_tour
										inner join qldl_dia_diem_du_lich
										on qldl_chi_tiet_tour.MA_DIA_DIEM = qldl_dia_diem_du_lich.MA_DIA_DIEM 
										 where qldl_chi_tiet_tour.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 1,2";
						$query_dd2 = @mysql_query($sql_dd2,$conn);	
								$row_dd2 = @mysql_fetch_array($query_dd2);
						?>
                    <select name="dd2" id="dd2" class=" validate[trung[dd1],trung[dd3],trung[dd4],trung[dd5]]">
                    <option value="<?php echo $row_dd2['qldl_dia_diem_du_lich.MA_DIA_DIEM']?>" selected><?php echo $row_dd2['DIA_DIEM']?></option>
					<?php 
							$sql_dd="select * from qldl_dia_diem_du_lich order by MA_DIA_DIEM asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
							
						?>  
						<option value="<?php echo $row_dd['MA_DIA_DIEM'];?>"><?php echo $row_dd['DIA_DIEM'];?></option>
							<?php 
								}
							
							?> 
                           
                  </select></td>
                </tr>
                <tr>
                  <td>Địa điểm 3</td>
                  <td colspan="2">
                   <?php
				  
						$sql_dd3="select * from qldl_chi_tiet_tour
										inner join qldl_dia_diem_du_lich
										on qldl_chi_tiet_tour.MA_DIA_DIEM = qldl_dia_diem_du_lich.MA_DIA_DIEM 
										 where qldl_chi_tiet_tour.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 2,3";
						$query_dd3 = @mysql_query($sql_dd3,$conn);	
								$row_dd3 = @mysql_fetch_array($query_dd3);
						?>
                    <select name="dd3" id="dd3" class="validate[trung[dd1],trung[dd2],trung[dd4],trung[dd5]]">
                     <option value="<?php echo $row_dd3['qldl_dia_diem_du_lich.MA_DIA_DIEM']?>" selected><?php echo $row_dd3['DIA_DIEM']?></option>
					<?php 
							$sql_dd="select * from qldl_dia_diem_du_lich order by MA_DIA_DIEM asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_DIA_DIEM'];?>"><?php echo $row_dd['DIA_DIEM'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td>Địa điểm 4</td>
                  <td colspan="2">
                   <?php
				  
						$sql_dd4="select * from qldl_chi_tiet_tour
										inner join qldl_dia_diem_du_lich
										on qldl_chi_tiet_tour.MA_DIA_DIEM = qldl_dia_diem_du_lich.MA_DIA_DIEM 
										 where qldl_chi_tiet_tour.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 3,4";
						$query_dd4 = @mysql_query($sql_dd4,$conn);	
								$row_dd4 = @mysql_fetch_array($query_dd4);
						?>
                    <select name="dd4" id="dd4" class="validate[trung[dd1],trung[dd2],trung[dd3],trung[dd5]]">
                    <option value="<?php echo $row_dd4['qldl_dia_diem_du_lich.MA_DIA_DIEM']?>" selected><?php echo $row_dd4['DIA_DIEM']?></option>
					<?php 
							$sql_dd="select * from qldl_dia_diem_du_lich order by MA_DIA_DIEM asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_DIA_DIEM'];?>"><?php echo $row_dd['DIA_DIEM'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td>Địa điểm 5</td>
                  <td colspan="2">
                   <?php
				  
						$sql_dd5="select * from qldl_chi_tiet_tour
										inner join qldl_dia_diem_du_lich
										on qldl_chi_tiet_tour.MA_DIA_DIEM = qldl_dia_diem_du_lich.MA_DIA_DIEM 
										 where qldl_chi_tiet_tour.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 4,5";
						$query_dd5 = @mysql_query($sql_dd5,$conn);	
								$row_dd5 = @mysql_fetch_array($query_dd5);
						?>
                    <select name="dd5" id="dd5" class="validate[trung[dd1],trung[dd2],trung[dd3],trung[dd4]]">
                     <option value="<?php echo $row_dd5['qldl_dia_diem_du_lich.MA_DIA_DIEM']?>" selected><?php echo $row_dd5['DIA_DIEM']?></option>
					<?php 
							$sql_dd="select * from qldl_dia_diem_du_lich order by MA_DIA_DIEM asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_DIA_DIEM'];?>"><?php echo $row_dd['DIA_DIEM'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td colspan="3" align="center"><strong>Cập nhật phương tiện</strong></td>
                </tr>
                <tr>
                  <td>Phương tiện 1</td>
                  <td colspan="2">
                  <?php
				  
						$sql_pt1="select * from qldl_chi_tiet_phuong_tien
										inner join qldl_phuong_tien
										on qldl_chi_tiet_phuong_tien.MA_PHUONG_TIEN = qldl_phuong_tien.MA_PHUONG_TIEN 
										 where qldl_chi_tiet_phuong_tien.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 0,1";
						$query_pt1 = @mysql_query($sql_pt1,$conn);	
								$row_pt1 = @mysql_fetch_array($query_pt1);
						?>
                  <select name="pt1" id="pt1" class="validate[trung[pt2],trung[pt3],trung[pt4]">
                    <option value="<?php echo $row_pt1['qldl_phuong_tien.MA_PHUONG_TIEN']?>" selected><?php echo $row_pt1['TEN_PHUONG_TIEN']?></option>
					<?php 
							$sql_dd="select * from qldl_phuong_tien order by MA_PHUONG_TIEN asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_PHUONG_TIEN'];?>"><?php echo $row_dd['TEN_PHUONG_TIEN'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td>Phương tiện 2</td>
                  <td colspan="2">
                   <?php
				  
						$sql_pt2="select * from qldl_chi_tiet_phuong_tien
										inner join qldl_phuong_tien
										on qldl_chi_tiet_phuong_tien.MA_PHUONG_TIEN = qldl_phuong_tien.MA_PHUONG_TIEN 
										 where qldl_chi_tiet_phuong_tien.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 1,2";
						$query_pt2 = @mysql_query($sql_pt2,$conn);	
								$row_pt2 = @mysql_fetch_array($query_pt2);
						?>
                  <select name="pt2" id="pt2" class="validate[trung[pt1],trung[pt3],trung[pt4]]">
                    <option value="<?php echo $row_pt2['qldl_phuong_tien.MA_PHUONG_TIEN']?>" selected><?php echo $row_pt2['TEN_PHUONG_TIEN']?></option>
					<?php 
							$sql_dd="select * from qldl_phuong_tien order by MA_PHUONG_TIEN asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_PHUONG_TIEN'];?>"><?php echo $row_dd['TEN_PHUONG_TIEN'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td>Phương tiện 3</td>
                  <td colspan="2">
                  <?php
				  
						$sql_pt3="select * from qldl_chi_tiet_phuong_tien
										inner join qldl_phuong_tien
										on qldl_chi_tiet_phuong_tien.MA_PHUONG_TIEN = qldl_phuong_tien.MA_PHUONG_TIEN 
										 where qldl_chi_tiet_phuong_tien.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 2,3";
						$query_pt3 = @mysql_query($sql_pt3,$conn);	
								$row_pt3 = @mysql_fetch_array($query_pt3);
						?>
                  <select name="pt3" id="pt3" class="validate[trung[pt1],trung[pt2],trung[pt4]]">
                    <option value="<?php echo $row_pt3['qldl_phuong_tien.MA_PHUONG_TIEN']?>" selected><?php echo $row_pt3['TEN_PHUONG_TIEN']?></option>
					<?php 
							$sql_dd="select * from qldl_phuong_tien order by MA_PHUONG_TIEN asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_PHUONG_TIEN'];?>"><?php echo $row_dd['TEN_PHUONG_TIEN'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                 <tr>
                  <td>Phương tiện 4</td>
                  <td colspan="2">
                   <?php
				  
						$sql_pt4="select * from qldl_chi_tiet_phuong_tien
										inner join qldl_phuong_tien
										on qldl_chi_tiet_phuong_tien.MA_PHUONG_TIEN = qldl_phuong_tien.MA_PHUONG_TIEN 
										 where qldl_chi_tiet_phuong_tien.MA_TOUR='".$_GET['id_edit_tour']."' LIMIT 3,4";
						$query_pt4 = @mysql_query($sql_pt4,$conn);	
								$row_pt4 = @mysql_fetch_array($query_pt4);
						?>
                  <select name="pt4" id="pt4" class="validate[trung[pt1],trung[pt3],trung[pt2]]">
                     <option value="<?php echo $row_pt4['qldl_phuong_tien.MA_PHUONG_TIEN']?>" selected><?php echo $row_pt4['TEN_PHUONG_TIEN']?></option>
					<?php 
							$sql_dd="select * from qldl_phuong_tien order by MA_PHUONG_TIEN asc";
							$query_dd = @mysql_query($sql_dd,$conn);	
							if($query_dd)while($row_dd = @mysql_fetch_array($query_dd)){
						?>  
						<option value="<?php echo $row_dd['MA_PHUONG_TIEN'];?>"><?php echo $row_dd['TEN_PHUONG_TIEN'];?></option>
							<?php }?> 
                  </select></td>
                </tr>
                <tr>
                  <td colspan="3" align="left"><input type="submit" name="btn_edit_tour" id="btn_edit_tour" value="Lưu" /> 
                   <input type="submit" name="btn_huy" id="btn_huy" value="Hủy" />
                  
                  </td>
                  </tr>
                <tr>
                  <td colspan="3" align="left"><input type="submit" name="btn_them_quoc_gia" id="btn_them_quoc_gia" value="Thêm quốc gia" /> 
                   <input type="submit" name="btn_them_thanh_pho" id="btn_them_thanh_pho" value="Thêm thành phố" /></td>
                  </tr>
                
              </tbody>
            </table>
            </form>
          </div></td>
          <td width="70%"><div style=" padding:0px; border-top: medium none; border-bottom: medium none; overflow: hidden; height: auto; width:100%" align="left">
            <form action="" method="post" name="form_view" id="form_view">
            <table width="100%" border="1" bordercolor="#666666" class="adminlist_tt">
              <thead>
                <tr>
                  <th colspan="7" align="center"> Danh sách tour </th>
                  <?php include('tour/del.php'); ?>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td width="55">Mã tour</td>
                  <td width="147">Tên tour</td>
                  <td width="89" align="center">Giá</td>
                  <td width="121">Thời gian khởi hành</td>
                  <td width="58" align="center">Số ngày</td>
                  <td width="70">Số chỗ </td>
                  <td width="115">Cập nhật</td>
                  </tr>
                   <?php
				$stt=0;
	$sql="select * from qldl_tour";
	$query = @mysql_query($sql,$conn);	
	if(!$query) echo "Query error to display.";
	else while($row = @mysql_fetch_array($query)){
		$stt++;
			?>	
                <tr>
                  <td><?php echo $row['MA_TOUR'];?></td>
                  <td><?php echo $row['TEN_TOUR'];?></td>
                  <td><?php echo $row['GIA'];?></td>
                  <td> <?php
				  $date = $row['TG_KHOI_HANH'];
					$arr_date = explode("-",$date);
					$day = $arr_date[2];
					$month = $arr_date[1];
					$year = $arr_date[0];
					$ngay_kh = $day."/".$month."/".$year;	
				  echo $ngay_kh;?></td>
                  <td><?php echo $row['SO_NGAY'];?></td>
                  <td><?php echo $row['SO_CHO'];?></td>
                  <td><a href="index.php?page=id_edit_tour&amp;id_edit_tour=<?php echo $row['MA_TOUR'];?>&amp;id_kt=<?php echo $row['MA_KIEU'];?>">Sửa</a> || 
                  <a onclick="Del_Info('index.php?page=tour&amp;id_del_tour=<?php echo $row['MA_TOUR'];?>&amp;id_photo_tour=<?php echo $row['HINH_ANH']; ?>');" href="#">Xóa</a></td>
                  </tr>
                  <?php } ?>
                 </tbody>
         		</table>
            </form>
          </div></td>
        </tr>
      </table>
  </div>
  </div>
</div>
